package com.itjoyee.redis.benchmark.jedis;

import com.itjoyee.redis.benchmark.base.Bench;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * 
 */
public abstract class JedisBench implements Bench<JedisPool> {

    @Override
    public JedisPool createInstance(int connections, String host) {
        String[] parts = host.split(":");
        JedisPool jp = new JedisPool(parts[0], Integer.valueOf(parts[1]));
        Jedis jedis = jp.getResource();
        jedis.flushDB();
        jedis.close();
        return jp;
    }

    @Override
    public void shutdown(JedisPool instance) {
        instance.close();
    }
    
}
